package cn.edu.jxau.controller;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import cn.edu.jxau.domain.post;
import cn.edu.jxau.service.queryPost;

public class findReplyServlet extends HttpServlet {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	@Override
	protected void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {

		queryPost queryPost = new queryPost();

		String postId = request.getParameter("postId");// 获取发帖id
		
		queryPost.updatePageView(postId);//浏览量加1

		request.setAttribute("posts", queryPost.findById(postId));// 得到该帖的全部信息封装在map集合键-post
																	// 值-userInfo

		request.setAttribute("replys", queryPost.findAllReplyBy(postId));// 得到全部的回复

		request.getRequestDispatcher("content.jsp").forward(request, response);
	}

	protected void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {

		queryPost queryPost = new queryPost();

		String postId = (String) request.getAttribute("postId");// 获取发帖id
		System.out.println(postId);
		request.setAttribute("posts", queryPost.findById(postId));// 得到该帖的全部信息封装在map集合键-post
																	// 值-userInfo

		request.setAttribute("replys", queryPost.findAllReplyBy(postId));// 得到全部的回复

		request.getRequestDispatcher("content.jsp").forward(request, response);
	}

}
